package com.zcxy360.sandtable.util;

import java.io.File;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;

public class PdfUtil {
	public static void main(String[] args) {
		System.out.println(readPdf("d:/res/信函.pdf"));
	}
	  /**
     * 读取pdf中文字信息(全部)
     */
    public static String readPdf(String inputFile){
        //创建文档对象
        PDDocument doc =null;
        String content="";
        try {
            //加载一个pdf对象
            doc =PDDocument.load(new File(inputFile));
            //获取一个PDFTextStripper文本剥离对象  
            PDFTextStripper textStripper =new PDFTextStripper();
            content=textStripper.getText(doc);
            doc.close();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("读取pdf文件失败");
        }
        return content;
    }
}
